home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / progrmng / mlpmodul.sit / MacLogimoPlus Documentation / DEF3 Files / MacBase.DEF / MacBase.DEF
Encoding:
Modula Definition  |  1990-06-14  |  4.1 KB  |  90 lines  |  [TEXT/PMED]

  1. DEFINITION MODULE MacBase; (* Franz Kronseder,ETHZ, 31.05.85 *)
  2.                            (* last modified 13.08.85 fxk     *)
  3.  
  4. (* This a lowest level MODULE, allowing MODULA-2 programs created by *)
  5. (* the 5-Pass-Compiler to run on the Apple Macintosh ,   *)
  6. (* and use the OS-routines and ToolBox-Routines in the ROM           *)
  7.  
  8. (* Executable Modula-2 program code is output by the Modula linker *)
  9. (* and stored in the data-fork of a file named <modulename>.LOD    *)
  10. (* A reloction loader, implemented as a Macintosh Application in   *)
  11. (* native Lisa-Pascal places the code into a segment of the application *)
  12. (* heap and performs a JSR to the entrypoint of the MODULA-Program. *)
  13.  
  14. (* The Pascal Loader and the Modula program exchange information about   *)
  15. (* the memory layout and CPU registers in the RootRecord data structure. *)
  16. (* MacBase offers several trap procedures for accessing the ROM routines *)
  17. (* via the Line 1010 unimplemented instruction trap of the 68000 CPU.    *)
  18. (*-----------------------------------------------------------------------*)
  19.  FROM SYSTEM IMPORT ADDRESS;
  20.  EXPORT QUALIFIED MacNIL,
  21.                   RootRecType, RootRecord,
  22.           ExitToShell,ErrorProc,TellError,
  23.                   StrPtr,LongInt,LongWord,Byte,OsType,Point,
  24.           OsErr,Handle,
  25.                   PTRAP,PTRAP1,PTRAP2,trapnr,traparg,
  26.                   inlineTrap,SyncCoreTrap,AsyncCoreTrap,PackageTrap,
  27.           adjCHAR ,adjPoint;
  28.         
  29. TYPE
  30.  StrPtr   = ADDRESS; (* pointer to a pascal string *)
  31.  LongInt  = ADDRESS; (* 32 bit *)
  32.  LongWord = ADDRESS;
  33.  Handle   = POINTER TO ADDRESS;
  34.  OsErr    = INTEGER;
  35.  Byte = CHAR;         (* 8 bit *)
  36.  OsType = ARRAY[0..3] OF CHAR;
  37.  Point = RECORD v:INTEGER; (* vertical *)
  38.                 h:INTEGER; (* horizontal *)
  39.          END;
  40.        RootRecType  = RECORD
  41.                        LoadKey   : CARDINAL;
  42.                        Layer0Base: ADDRESS;
  43.                        Layer0Code: ADDRESS;
  44.                        Layer0Top : ADDRESS;
  45.                        StackLimit : ADDRESS;          (* lower limit, first address not in stack *)
  46.                        PascalA5Register : ADDRESS;    (* SYSTEMX saves environment *)
  47.                        PascalA6Register : ADDRESS;    (* for return to rootloader  *)
  48.                        PascalA7Register : ADDRESS;
  49.                        patch1,patch2,patch3 : ADDRESS;  (* reserve pointers *)
  50.                        LoadfName : ARRAY [0..63] OF CHAR;
  51.                       END;
  52.  
  53. (* The above record is initialized by SYSTEMX. The same type is declared in *)
  54. (* the Pascal Loader M2EXEC and passed to SYSTEMX at program start time.    *)
  55. (* Both the Pascal and the Modula RootRecord must have the same memory layout *)
  56.  
  57. TYPE ErrorProc = PROCEDURE(StrPtr,BOOLEAN);
  58.  
  59.  VAR   RootRecord   : RootRecType; (* initialized by SYSTEMX *)
  60.        MacNIL : ADDRESS; (* NIL constant different in Pascal *)
  61.                          (* MacNIL=00000000h; ModulaNIL=0FFFFFFFFh *)
  62.        TellError: ErrorProc;
  63.  
  64.  VAR trapnr :CARDINAL;traparg:CARDINAL; (* for PTRAP1 *)
  65.   (* here are the currently implemented traps *)
  66.   PROCEDURE PTRAP;  (* for QuickDraw, EventMgr *)
  67.   PROCEDURE PTRAP1; (* for SFPackage *)
  68.   PROCEDURE PTRAP2; (* for the FileSystem Core Routine Traps *)
  69.   (* for interfacing with the 1010-Emulator-Traps to the Macintosh Operating
  70.      System . The MODULA-Routine that calls PTrap needs to have the same
  71.      parameterlist as the corresponding Pascal-Procedure in the MacOS expects.
  72.      Store the trapnumber 0AxxxH in trapnr  *)
  73.  
  74.   (* here are the new, NOT YET implemented traps *)
  75.   PROCEDURE inlineTrap   (nr:CARDINAL);
  76.   PROCEDURE SyncCoreTrap (nr:CARDINAL);
  77.   PROCEDURE AsyncCoreTrap(nr:CARDINAL);
  78.   PROCEDURE PackageTrap  (nr,sel:CARDINAL);
  79.  
  80.   (* here are ** NOT YET implemented ** operations for adjusting stacked parameters *)
  81.   PROCEDURE adjCHAR (VAR ch:CHAR);
  82.   PROCEDURE adjPoint(VAR Pt:Point);
  83.  
  84. PROCEDURE ExitToShell;
  85. (* ExitToShell provides an emergency exit for the application,  *)
  86. (* without touching the stack. It simply launches the Finder,   *)
  87. (* starting it up after freeing the application heap            *)
  88. (*  this is implemented!  *)
  89. END MacBase.
  90.